package com.itcast.dao.impl;

import com.itcast.dao.DeptDao;
import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Repository;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@Repository
public class DeptDaoImpl implements DeptDao {
    public List<String> getData() throws IOException {
    //1.加载dept.txt文件
    //1.1获取类加载器
    ClassLoader classLoader = this.getClass().getClassLoader();
    //1.2加载resource中的文件通过流到内存中
    InputStream stream = classLoader.getResourceAsStream("dept.txt");
    List<String> strings = IOUtils.readLines(stream, "utf-8");
    return strings;
    }
}
